package servlets;

import java.io.BufferedReader;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet STUB
 */
@WebServlet("/Stub")
public class Stub extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("POST Partito!");
		
		StringBuffer jb = new StringBuffer();
		String line = null;
		try {
			BufferedReader reader = request.getReader();
		    while ((line = reader.readLine()) != null)
		    	jb.append(line);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("");
		System.out.println("RICHIESTA: " + jb.toString());
		System.out.println("SOAP ACTION: " + request.getHeader("SOAPAction"));
		
		//Invia la response
		String r="Ritorno!";
		ServletOutputStream respStream=response.getOutputStream();
		respStream.write(r.getBytes());
		respStream.close();
	}

}
